package top.yocloud.server;

import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
import top.yocloud.service.impl.HelloServiceImpl;

/**
 * 服务端启动入口
 * <br/>
 * created by 谭亚军 at 2023/5/25 14:44
 */
public class Server {
    public static void main(String[] args) {
        // 发布WS服务工厂
        JaxWsServerFactoryBean factoryBean = new JaxWsServerFactoryBean();
        // 设置服务地址
        factoryBean.setAddress("http://localhost:80/ws/hello");
        // 设置服务类
        factoryBean.setServiceBean(new HelloServiceImpl());
        // 添加日志拦截器：输入、输出，用于观察SOAP请求及响应内容
        factoryBean.getInInterceptors().add(new LoggingInInterceptor());
        factoryBean.getOutInterceptors().add(new LoggingOutInterceptor());
        // 发布服务
        factoryBean.create();
        System.out.println("发布服务成功...");
    }
}
